// 管理员权限系统类型定义

export type UserRole = 'user' | 'moderator' | 'admin'

export interface UserRoleRecord {
  id: number
  user_id: string
  role: UserRole
  granted_by?: string
  granted_at: string
  updated_at: string
}

export interface RoleChangeLog {
  id: number
  user_id: string
  old_role?: UserRole
  new_role: UserRole
  changed_by?: string
  changed_at: string
  reason?: string
}

export interface SetUserRoleParams {
  target_user_id: string
  new_role: UserRole
  reason?: string
}

export interface BatchSetUserRoleParams {
  user_id: string
  role: UserRole
}

export interface BatchSetUserRolesParams {
  user_roles: BatchSetUserRoleParams[]
  reason?: string
}

export interface SetUserRoleResponse {
  success: boolean
  message?: string
  error?: string
  old_role?: UserRole
  new_role?: UserRole
}

export interface BatchSetUserRolesResponse {
  success: boolean
  results: SetUserRoleResponse[]
  summary: {
    total: number
    success: number
    error: number
  }
  error?: string
}

export interface UserWithRole {
  id: string
  name: string
  avatar?: string
  bio?: string
  isAi: boolean
  followers: number
  following: number
  uploads: number
  createdAt: string
  role: UserRole
  granted_at?: string
  granted_by?: string
}

export interface AdminStats {
  total_users: number
  total_movies: number
  total_comments: number
  users_by_role: {
    user: number
    moderator: number
    admin: number
  }
  recent_activity: {
    new_users: number
    new_movies: number
    new_comments: number
  }
}

export interface ContentModeration {
  id: number
  type: 'movie' | 'comment' | 'user'
  content_id: string
  user_id: string
  user_name: string
  content: string
  status: 'pending' | 'approved' | 'rejected'
  moderated_by?: string
  moderated_at?: string
  reason?: string
  created_at: string
}

export interface ModerationAction {
  content_id: string
  action: 'approve' | 'reject' | 'delete'
  reason?: string
}

export interface ModerationResponse {
  success: boolean
  message?: string
  error?: string
}
